﻿// ______________________________________________________________
//
// Soft mask effect class - Liam O'Donnell
// Creates a blurred soft mask
// ______________________________________________________________
//

// ______________________________________________________________
//
// USAGE:
// - Create/attach a movieclip that's an instance of SoftMask
// - You can alternatively use the static method 'create'
// ______________________________________________________________
//

import flash.filters.BlurFilter;
import com.spikything.utils.SpikyTools;

class com.spikything.gfx.SoftMask extends MovieClip {

	// ______________________________________________________
	//
	// CONSTANTS
	// ______________________________________________________
	//

	private var blurxy 		:Number;
	private var quality 	:Number;

	// ______________________________________________________
	//
	// CONSTRUCTOR
	// ______________________________________________________
	//

	function SoftMask () {}

	// ______________________________________________________
	//
	// PUBLIC METHODS
	// ______________________________________________________
	//

	public function onLoad ():Void {
		init();
	}

	// ______________________________________________________
	//
	// PRIVATE METHODS
	// ______________________________________________________
	//

	private function init ():Void {
		_x += blurxy*quality/2;
		_y += blurxy*quality/2;
		_width -= blurxy*quality;
		_height -= blurxy*quality;
		//mask = attachMovie("mask","mask",this.getNextHighestDepth(),{_x:blurxy*quality/2,_y:blurxy*quality/2,_width:980-(blurxy*quality),_height:680-(blurxy*quality)});
		filters = [new BlurFilter(blurxy,blurxy,quality)];
		cacheAsBitmap = true;
	}


	// ______________________________________________________
	//
	// STATIC METHODS
	// ______________________________________________________
	//

	public static function create (_base:MovieClip,_id:String,_initObj:Object,_depth:Number):SoftMask {
		return SpikyTools.attachClass(_base,_id,SoftMask,_initObj,null,_depth);
	}

}